const state = {
    menus: [],
    levelMenus: [],
    allMenus: []
}
const mutations = {
    // 设置菜单
    setMenus(state, menus) {
        menus.forEach(element => {
            if (element.children && element.children.length) {
                element.isShowChild = true
                element.path = ''
            }
        });
        state.menus = menus
    },
    // 设置全量数据菜单
    setAllMenus(state, menus) {
        state.allMenus = menus
    },
    // 保存只有一个层级的菜单，用于寻找父级title
    setLevelMenus(state, menus) {
        state.levelMenus = menus
    }
}

const getters = {
    getMenus(state) {
        return state.menus
    },
    getLevelMenus(state) {
        return state.getLevelMenus
    },
    getAllMenus(state) {
        return state.allMenus
    }
}

const actions = {
    
}

export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
}
